<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<f:view>

	<f:metadata>
		<f:viewAction action="#{menuMB.updateMenu(2)}" />
	</f:metadata>

	<ui:composition template="/WEB-INF/templates/defaultLayout.xhtml">
		<!-- Definiendo la cabecera de la pagina -->
		<ui:define name="title">
			<h:outputText value="Cerrar Caja" />
		</ui:define>

		<!-- Definiendo el cuerpo de la pagina -->
		<ui:define name="content">

			<h:outputStylesheet library="css" name="main.css" />
			<br />
			<h:form id="closeCaja">
				<h:panelGroup rendered="#{abrirCajaBean.failure}">
					<div class="p6n-api-access-in-page-error" style="left: 516px;">
						<div>
							<div>
								<p>
									<h:messages />
								</p>
							</div>
							<div style="text-align: center;">
								<h:commandLink value="Volver"
									action="/caja/operaciones/index?faces-redirect=true"
									immediate="true" styleClass="p6n-api-access-in-page-error-link" />
							</div>
						</div>
					</div>
					<div class="modal-dialog-bg"
						style="opacity: 0.4; width: 1366px; height: 602px;"></div>
				</h:panelGroup>


				<div style="margin-left: 50px;">
					<div>
						<div>
							<div>
								<h:commandButton action="#{abrirCajaBean.descongelar()}"
									value="Descongelar" styleClass="action green"
									style="float:none;" />
								<h:commandButton action="#{abrirCajaBean.congelar()}"
									value="Congelar" styleClass="action red" style="float:none;" />
							</div>
							<br /> <br />
							<div class="p6n-api-consent-screen-title">Cerrar Caja</div>
							<div class="p6n-api-consent-screen-inputs">
								<div class="p6n-api-consent-screen-input-section">
									<div class="p6n-api-consent-screen-label" style="width: 150px;">AGENCIA</div>
									<div>
										<h:outputLabel value="#{abrirCajaBean.agencia.denominacion}" />
									</div>
								</div>
								<div class="p6n-api-consent-screen-input-section">
									<div style="display: inline-block;">
										<div class="p6n-api-consent-screen-label"
											style="width: 150px;">CAJA</div>
										<div>
											<div>
												<h:outputLabel value="#{abrirCajaBean.caja.denominacion}" />
											</div>
										</div>
									</div>
									<div style="display: inline-block;">
										<div class="p6n-api-consent-screen-label"
											style="width: 150px;">ABREVIATURA</div>
										<div>
											<h:outputLabel value="#{abrirCajaBean.caja.abreviatura}" />
										</div>
									</div>
									<div style="display: inline-block;">
										<div class="p6n-api-consent-screen-label"
											style="width: 150px;">ESTADO</div>
										<div>
											<h:outputLabel
												value="#{abrirCajaBean.caja.estadoapertura.denominacion}" />
										</div>
									</div>
									<div style="display: inline-block;">
										<div class="p6n-api-consent-screen-label"
											style="width: 150px;">MOVIMIENTOS</div>
										<div>
											<h:outputLabel id="hola"
												value="#{abrirCajaBean.historialcaja.estadomovimiento.denominacion}" />
										</div>
									</div>
								</div>
								<br />
								<div>
									<p:accordionPanel multiple="true"
										value="#{abrirCajaBean.mapDetalleHistorialcajaApertura.entrySet().toArray()}"
										var="boveda">
										<p:tab title="#{boveda.key.denominacion}">
											<p:panelGrid columns="2" style="margin-left:1px;">
												<p:outputPanel>
													<p:dataTable var="cajaDetalle" value="#{boveda.value}"
														rowKey="#{cajaDetalle}" rowIndexVar="row">
														<f:facet name="header">
															<h:outputText style="font-size: 13px;"
																value="DETALLE INICIO DEL DÍA" />
														</f:facet>
														<p:column headerText="Nro" width="15"
															style="text-align:center;height:19px">
															<h:outputText value="#{row + 1}" />
														</p:column>
														<p:column headerText="Denominacion" width="40"
															style="text-align:right;">
															<h:outputText
																value="#{cajaDetalle.denominacionmoneda.denominacion}" />
														</p:column>
														<p:column headerText="Cantidad" width="100"
															style="text-align:right;">
															<h:outputText value="#{cajaDetalle.cantidad}" />
														</p:column>
														<p:column headerText="Total" width="150"
															style="text-align:right;">
															<h:outputText value="#{cajaDetalle.getSubtotal()}" />
														</p:column>
														<f:facet name="footer">
															<h:outputText style="font-size: 13px;"
																value="TOTAL: #{boveda.key.abreviatura}" />
															<h:outputText style="font-size: 13px;"
																value="#{abrirCajaBean.getTotalAbrir(boveda.key)}" />
														</f:facet>
													</p:dataTable>
												</p:outputPanel>
												<p:outputPanel>
													<p:dataTable id="tabla" var="cajaDetalle"
														value="#{abrirCajaBean.retornarDetalle(boveda.key)}"
														rowKey="#{cajaDetalle}" rowIndexVar="row">
														<f:facet name="header">
															<h:outputText style="font-size: 13px;"
																value="DETALLE FINAL DEL DÍA" />
														</f:facet>
														<p:column headerText="Nro" width="15"
															style="text-align:center;">
															<h:outputText value="#{row + 1}" />
														</p:column>
														<p:column headerText="Denominacion" width="40"
															style="text-align:right;">
															<h:outputText
																value="#{cajaDetalle.denominacionmoneda.denominacion}" />
														</p:column>
														<p:column headerText="Cantidad" width="100"
															style="text-align:right;">
															<h:inputText id="txtCantidadMoneda"
																value="#{cajaDetalle.cantidad}" required="true"
																maxlength="6" requiredMessage="requerido"
																styleClass="jfk-textinput p6n-api-consent-screen-homepage-url label-input-label"
																style="text-align:left; width:100px; height:20px">
																<f:ajax event="blur" execute="@this" render="tabla" />
															</h:inputText>
															<div
																class="p6n-api-consent-screen-input-error p6n-api-consent-screen-product-name-error-msg">
																<h:message for="txtCantidadMoneda" />
															</div>
														</p:column>
														<p:column headerText="Total" width="150"
															style="text-align:right;">
															<h:outputText value="#{cajaDetalle.getSubtotal()}" />
														</p:column>
														<f:facet name="footer">
															<h:outputText style="font-size: 13px;"
																value="TOTAL: #{boveda.key.abreviatura}" />
															<h:outputText style="font-size: 13px;"
																value="#{abrirCajaBean.getTotal(boveda.key)}" />
														</f:facet>
													</p:dataTable>
												</p:outputPanel>
											</p:panelGrid>
										</p:tab>
									</p:accordionPanel>
								</div>
								<div class="sf-buttons" style="float: left;">
									<h:commandButton value="Cerrar"
										action="#{abrirCajaBean.verificarSaldos()}"
										styleClass="action blue" />
									<h:commandButton action="/caja/index?faces-redirect=true"
										value="Cancelar" styleClass="action" immediate="true" />
								</div>
							</div>

						</div>
					</div>
				</div>
			</h:form>

			<h:panelGroup rendered="#{abrirCajaBean.dlgVerificarSaldos}">
				<h:form>
					<div class="modal-dialog-bg"
						style="opacity: 0.4; width: 1366px; height: 1800px;"></div>
					<div class="modal-dialog p6n-popup"
						style="left: 502px; top: 100px;">
						<div class="modal-dialog-title modal-dialog-title-draggable">
							<span class="modal-dialog-title-text">Verificacion de
								Saldos</span><span class="modal-dialog-title-close"></span>
						</div>
						<div class="modal-dialog-content ng-binding">
							<p:panelGrid columns="4">
								<ui:repeat
									value="#{abrirCajaBean.mapDiferenciaSaldos.entrySet().toArray()}"
									var="panelMoneda">
									<p:outputPanel>
										<label>--------------------------------------------------------</label>
										<h3 class="sf-label-bold">#{panelMoneda.key.denominacion}</h3>
										<div>
											<h:outputLabel
												value="#{abrirCajaBean.getMensajeSaldo(panelMoneda.value)}"
												styleClass="#{abrirCajaBean.getCompareBigdecimal(panelMoneda.value) != 0 ? 'sf-label-error' : ''}" />
											&nbsp;
											<h:outputLabel value="#{panelMoneda.value}" />
										</div>
										<div>
											<h:commandButton value="Crear pendiente"
												action="#{abrirCajaBean.cargarPendiente(panelMoneda.key)}" />
										</div>
										<label>------------------------------------------------------</label>
									</p:outputPanel>
								</ui:repeat>
							</p:panelGrid>
						</div>
						<div class="modal-dialog-buttons">
							<h:commandButton value="Cerrar caja"
								action="#{abrirCajaBean.closeCaja()}" styleClass="action blue">
							</h:commandButton>
							<h:commandButton value="Cancelar"
								action="#{abrirCajaBean.setDlgVerificarSaldos(false)}"
								immediate="true" />
						</div>
					</div>
				</h:form>
			</h:panelGroup>

			<h:panelGroup rendered="#{abrirCajaBean.successPendiente}">
				<div class="p6n-butterbar" id="p6n-manualbutterbar0"
					style="left: 25%;">
					<div>
						<h:messages />
					</div>
				</div>
			</h:panelGroup>

			<h:panelGroup rendered="#{abrirCajaBean.dlgCrearPendiente}">
				<h:form>
					<div class="modal-dialog-bg"
						style="opacity: 0.4; width: 1366px; height: 902px;"></div>
					<div class="modal-dialog p6n-popup" style="left: 452px; top: 50px;">
						<div class="modal-dialog-title modal-dialog-title-draggable"
							style="text-align: center; font-weight: bold; font-size: 16px;">
							<span class="modal-dialog-title-text">CREAR PENDIENTE</span><span
								class="modal-dialog-title-close"></span>
						</div>
						<div class="modal-dialog-content ng-binding">
							<div>
								<div class="p6n-api-consent-screen-inputs">
									<div class="p6n-api-consent-screen-input-section">
										<div class="p6n-api-consent-screen-label"
											style="width: 150px;">FECHA</div>
										<div>
											<h:outputText value="#{abrirCajaBean.fechaPendiente}">
												<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss a"
													timeZone="EST" />
											</h:outputText>
										</div>
									</div>
									<div class="p6n-api-consent-screen-input-section">
										<div class="p6n-api-consent-screen-label"
											style="width: 150px;">TIPO PENDIENTE</div>
										<div>
											<h:outputText
												value="#{abrirCajaBean.getMensajeTipoPendiente()}" />
										</div>
									</div>
									<div class="p6n-api-consent-screen-input-section">

										<div style="display: inline-block; width: 190px;">
											<div class="p6n-api-consent-screen-label">TIPO MONEDA</div>
											<div>
												<h:outputText
													value="#{abrirCajaBean.tipomonedaPendiente.denominacion}" />
											</div>
										</div>
										<div style="display: inline-block; width: 190px;">
											<div class="p6n-api-consent-screen-label">MONTO</div>
											<div>
												<h:outputText
													value="#{abrirCajaBean.tipomonedaPendiente.abreviatura} #{abrirCajaBean.montoPendiente}" />
											</div>
										</div>
									</div>
									<div class="p6n-api-consent-screen-input-section">
										<div class="p6n-api-consent-screen-label">OBSERVACIÓN</div>
										<div>
											<div>
												<p:inputTextarea rows="10" cols="60" queryDelay="750"
													minQueryLength="4" maxlength="300"
													value="#{abrirCajaBean.observacionPendiente}" />
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="modal-dialog-buttons">
							<h:commandButton action="#{abrirCajaBean.crearPendiente()}"
								value="Guardar" styleClass="action blue"
								onclick="onSubmitButton();" />
							<h:commandButton value="Cancelar"
								action="#{abrirCajaBean.cancelarPendiente()}" immediate="true"
								styleClass="action" />
						</div>
					</div>
				</h:form>
			</h:panelGroup>

			<h:panelGroup rendered="#{abrirCajaBean.success}">
				<h:form>
					<div class="modal-dialog-bg"
						style="opacity: 0.4; width: 1366px; height: 902px;"></div>
					<div class="modal-dialog p6n-popup"
						style="left: 452px; top: 150px;">
						<div class="modal-dialog-title modal-dialog-title-draggable">
							<span class="modal-dialog-title-text">Caja Cerrada
								Satisfactoriamente</span><span class="modal-dialog-title-close"></span>
						</div>
						<div class="modal-dialog-content ng-binding">
							<div>La caja se cerro correctamente...</div>
						</div>
						<div class="modal-dialog-buttons">
							<h:commandButton value="Salir"
								action="/caja/index?faces-redirect=true" immediate="true"
								styleClass="action" />
						</div>
					</div>
				</h:form>
			</h:panelGroup>

			<h:panelGroup rendered="#{abrirCajaBean.print}">
				<h:form>
					<div class="modal-dialog-bg"
						style="opacity: 0.4; width: 1366px; height: 902px;"></div>
					<div class="modal-dialog p6n-popup" style="left: 500px; top: 5px;">

						<div class="modal-dialog-content ng-binding">
							<h:form id="formPendiente">
								<div style="margin-left: 0px;">
									<h:panelGroup id="voucherPendiente">
										<table
											style="width: 400px; border: solid 1px #E9E6E6; margin-bottom: 0px;">
											<tr style="vertical-align: center;">
												<td colspan="1"
													style="width: 30%; text-align: center; font-weight: bold; font-size: 12px;">
													<p:graphicImage name="logo_coop_voucher.png"
														library="images/logo_coop" />
												</td>
												<td colspan="3"
													style="width: 70%; text-align: center; font-weight: bold; font-size: 14px; vertical-align: middle">
													<h:outputText value="C.A.C." /> <br /> <h:outputText
														style="font-size: 24px;" value="CAJA VENTURA" />
												</td>
											</tr>
											<tr style="vertical-align: center;">
												<td colspan="4"
													style="text-align: center; font-weight: bold; font-size: 13px;">PENDIENTE
													CAJA</td>
											</tr>
											<tr>
												<td style="font-weight: bold; font-size: 12px;" colspan="1">AGENCIA:</td>
												<td colspan="3">#{abrirCajaBean.agencia.denominacion}</td>
											</tr>
											<tr>
												<td style="font-weight: bold; font-size: 12px;" colspan="1">ID
													PENDIENTE:</td>
												<td colspan="3">#{abrirCajaBean.pendientecaja.idpendientecaja}</td>
											</tr>
											<tr>
												<td style="font-weight: bold; font-size: 12px;" colspan="1">TIPO
													PENDIENTE:</td>
												<td colspan="3">#{abrirCajaBean.pendientecaja.tipopendiente}</td>
											</tr>
											<tr>
												<td colspan="1" style="font-weight: bold; font-size: 12px;">FECHA:</td>
												<td colspan="3" style="font-size: 12px;"><h:outputText
														value="#{abrirCajaBean.pendientecaja.fecha}">
														<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss a"
															timeZone="EST" />
													</h:outputText></td>
											</tr>
											<tr>
												<td colspan="1" style="font-weight: bold; font-size: 12px;">MONEDA:</td>
												<td colspan="3" style="font-size: 12px;"><h:outputText
														value="#{abrirCajaBean.pendientecaja.tipomoneda.denominacion} (#{abrirCajaBean.pendientecaja.tipomoneda.abreviatura})" /></td>
											</tr>
											<tr style="vertical-align: center;">
												<td colspan="1" style="font-weight: bold; font-size: 12px;"><h:outputText
														value="MONTO:" /></td>
												<td colspan="3" style="font-size: 12px;"><h:outputText
														value="#{abrirCajaBean.pendientecaja.tipomoneda.abreviatura} #{abrirCajaBean.pendientecaja.monto}" />
												</td>
											</tr>
											<tr>
												<td colspan="1" style="font-weight: bold; font-size: 12px;">CAJA:</td>
												<td colspan="3" style="font-size: 12px;"><h:outputText
														value="#{abrirCajaBean.caja.denominacion} (#{abrirCajaBean.caja.abreviatura})" /></td>
											</tr>
											<tr>
												<td colspan="1" style="font-weight: bold; font-size: 12px;">USUARIO:</td>
												<td colspan="3" style="font-size: 12px;"><h:outputText
														value="#{usuarioMB.usuario.username}" /></td>
											</tr>
											<tr>
												<td colspan="1" style="font-weight: bold; font-size: 12px;">CAJERO:</td>
												<td colspan="3" style="font-size: 12px;"><h:outputText
														value="#{usuarioMB.usuario.trabajador.personanatural.tipodocumento.abreviatura} #{usuarioMB.usuario.trabajador.personanatural.numerodocumento}" />
													<br /> <h:outputText
														value="#{usuarioMB.usuario.trabajador.personanatural.apellidopaterno} #{usuarioMB.usuario.trabajador.personanatural.apellidomaterno} #{usuarioMB.usuario.trabajador.personanatural.nombres}" />
												</td>
											</tr>
											<tr>
												<td colspan="1" style="font-weight: bold; font-size: 12px;">OBSERVACIÓN:</td>
												<td colspan="3" style="font-size: 12px;"><p:inputTextarea
														value="#{abrirCajaBean.pendientecaja.observacion}"
														rows="3" cols="45" readonly="true" /></td>
											</tr>
											<tr>
												<td colspan="4">&nbsp;</td>
											</tr>
											<tr>
												<td colspan="4">&nbsp;</td>
											</tr>
											<tr>
												<td colspan="2" style="text-align: center;">-------------------------</td>
												<td colspan="2" style="text-align: center;">-------------------------</td>
											</tr>
											<tr>
												<td colspan="2"
													style="text-align: center; font-weight: bold; font-size: 12px;">JEFE
													DE CAJA</td>
												<td colspan="2"
													style="text-align: center; font-weight: bold; font-size: 12px;">CAJERO</td>
											</tr>
										</table>
									</h:panelGroup>
									<div style="margin-left: 10px;">
										<h:commandButton value="Imprimir" styleClass="action blue">
											<p:printer target="voucherPendiente" />
										</h:commandButton>
										<h:commandButton value="Salir"
											action="#{abrirCajaBean.cancelarDlgPrintPendiente()}" />
									</div>
								</div>
							</h:form>
						</div>
					</div>
				</h:form>
			</h:panelGroup>

		</ui:define>
	</ui:composition>
</f:view>
</html>